<?php
/**
 * Created by PhpStorm.
 * User: 王文凡<787802868@qq.com>
 * Date: 2016/9/28 0028
 * Time: 16:10
 */

namespace Common\Model;
use Think\Model;

class SubjectsModel extends Model
{
    protected $_validate = array(
        array('subject_name','require', '科目名称必须填写'),
        array('subject_name','','科目名称已经存在！',0,'unique',1),
    );
    public function adds(){
        if(!$this->create()){
            $arr['state']='error';
            $arr['info']=$this->getError();
            return $arr;
        }else{
            $_POST['create_time']=time();
            if($this->add($_POST)){
                $arr['state']='success';
                $arr['info']='添加成功';
            }else{
                $arr['state']='error';
                $arr['info']='添加失败';
            }
            return $arr;
        }
    }
}